package com.whmskj.xjlhbc.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.whmskj.xjlhbc.core.AjaxResult;
import com.whmskj.xjlhbc.service.IHomeService;
import com.whmskj.xjlhbc.vo.HomeDataChartVo;
import com.whmskj.xjlhbc.vo.HomeDataVo;
import com.whmskj.xjlhbc.vo.HomeRealinfoDataVo;
import com.whmskj.xjlhbc.vo.HomeVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


@RestController
@Tag(name = "首页",description = "首页")
@RequestMapping("/home")
public class HomeController {

    @Autowired
    private IHomeService service;

    //pc端首页
    @SaIgnore
    @GetMapping
    public AjaxResult home(){
        HomeVo result = service.query();
        return AjaxResult.success(result);
    }

    //移动端首页
    @GetMapping("/getHomeInfo")
    @Operation(description = "首页")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, HomeRealinfoDataVo.class})
    ))
    public AjaxResult getHomeInfo(){
        Object result = service.getHomeInfo();
        return AjaxResult.success(result);
    }

    @GetMapping("/jtzt")
    @Operation(description = "机台状态")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class})
    ))
    public AjaxResult jtzt(String workshop){
        Object result = service.jtzt(workshop);
        return AjaxResult.success(result);
    }

    @GetMapping("/jtztListGroupByName")
    @Operation(description = "机台状态")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class})
    ))
    public AjaxResult jtztListGroupByName(String status,String workshop){
        Object result = service.jtztListGroupByName(status,workshop);
        return AjaxResult.success(result);
    }

    @GetMapping("/data")
    @Operation(description = "本月统计数据")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, HomeDataVo.class})
    ))
    public AjaxResult data(){
        HomeDataVo result = service.data();
        return AjaxResult.success(result);
    }

    @GetMapping("/realInfoData")
    @Operation(description = "织布车间实时数据")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, HomeRealinfoDataVo.class})
    ))
    public AjaxResult realInfoData(){
        Object result = service.realInfoData();
        return AjaxResult.success(result);
    }

    @GetMapping("/cldb")
    @Operation(description = "班组产量对比")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class})
    ))
    public AjaxResult cldb(){
        List<Map<String,Object>> result = service.cldb();
        return AjaxResult.success(result);
    }

    @GetMapping("/cldbWeek")
    @Operation(description = "近一周班组产量对比")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, HomeDataChartVo.class})
    ))
    public AjaxResult cldbWeek(){
        HomeDataChartVo result = service.cldbWeek();
        return AjaxResult.success(result);
    }

    @GetMapping("/clMonth")
    @Operation(description = "近一月累计产量对比")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, HomeDataChartVo.class})
    ))
    public AjaxResult clMonth(){
        HomeDataChartVo result = service.clMonth();
        return AjaxResult.success(result);
    }

}
